package PL.practica1;

public class Back {

	private String signature;
	private String cadena;
	
	public Back() {
		signature = "";
		cadena = "";
	}
	
	
	public String getSignature() {
		return signature;
	}
	public void setSignature(String signature) {
		this.signature = signature;
	}
	
	public String getCadena() {
		return cadena;
	}
	public void setCadena(String cadena) {
		this.cadena = cadena;
	}
	
	
	
	public void rellenarBack (String texto) {
		setCadena(texto);
		setSignature(buscarEtiqueta(getCadena(), "<signature>", "</signature>"));
	}
	
	
	public String buscarEtiqueta (String cadena, String etiquetaIni, String etiquetaFin) {
		
		int ini = cadena.indexOf(etiquetaIni);
		int fin = cadena.indexOf(etiquetaFin);
		
		return cadena.substring(ini, fin).replaceFirst(etiquetaIni, "");
	}
	
	public String translateSignature() {
		return "<P CLASS=\"signature\" span style=\"color: A96060;\">"+getSignature()+"</P>";
	}
}
